<?php
require_once 'Framework/Controller/Request/Http.php';
require_once 'application/models/Room.php';
class Stat_Users
{
	/**
	 * кол-во новых регистраций
	 * @param int[optional] $type  тип пользователя (0=гость, 1=пользователь)
	 * @param datetime[optional] $dateTo  с даты
	 * @param datetime[optional] $dateFrom  по дату
	 */
	public static function getNewUsers($type = 0, $dateTo='',$dateFrom='')
	{
		if (''==$dateFrom) $dateFrom = "SUBTIME( NOW() - INTERVAL 1 week,CURRENT_TIME )";
		if (''==$dateTo) $dateTo = "NOW()";

		return Framework_Registry::get('dbh')->
			selectCell("SELECT COUNT(user_id)
						FROM user
						WHERE user_created BETWEEN $dateFrom AND $dateTo
						AND user_password IS { NOT } NULL",
						($type) ? 1 : DBSIMPLE_SKIP);
	}
		
}